package ari.com.eft.jobs;

import java.io.IOException;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.ari.eft.transport.tls.EPPTLSTransport;
import com.ari.eft.transport.tls.SessionConfigurationException;
import com.ari.eft.transport.tls.SessionOpenException;

/* Name does not sound alright. Think of a better name */

public class EFTSessionJob implements Job {
	EPPTLSTransport tlsTransport = null;

	public void execute(final JobExecutionContext context)
			throws JobExecutionException {
		System.out.println("[EFTSessionJob] starting now");
		try {
			tlsTransport = EFTTransportMgr.getEPPTransportInstance();
			tlsTransport.open();
		} catch (final SessionOpenException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (final SessionConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String incomingData = null;
		while (true) {
			try {
				incomingData = tlsTransport.read();
				System.out.println("Read the following" + incomingData);
			} catch (final IOException e) {
				e.printStackTrace();
			}
		}

	}

}
